<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
        <link href="<?php echo base_url();?>img/favicon.ico" rel="shortcut icon" />
		<title><?php echo "TOKO ELEKTRONIK SONY PROGRAM GUDANG"; ?></title>
        <?php if( ($this->session->userdata("type_user") != "user") && ($this->session->userdata("type_user") != "") ){ ?>
        <link rel="stylesheet" href="<?php echo base_url();?>css/admin.css" type="text/css" />
        <?php } ?>
        <link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" />
        <link rel="stylesheet" href="<?php echo base_url();?>css/global.css" type="text/css" />
       
        <!--<link rel="stylesheet" href="<?php echo base_url();?>css/jquery-ui-1.7.2.custom.css" type="text/css" />-->
        <link rel="stylesheet" href="<?php echo base_url();?>css/jquery-ui-1.10.3.custom.css" type="text/css" />
 		<link rel="stylesheet" href="<?php echo base_url();?>css/jquery-ui-timepicker-addon.css" type="text/css" />
         
       <!-- <link rel="stylesheet" href="<?php /*echo base_url(); ok*/?>css/autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" />-->
        

		
		<script src="<?php echo base_url();?>jquery/jquery-1.9.1.js"></script>
		<script src="<?php echo base_url();?>jquery/ui/jquery-ui-1.10.3.custom.js"></script>
        <script src="<?php echo base_url();?>jquery/ui/jquery-ui-timepicker-addon.js"></script>
		<script src="<?php echo base_url();?>js/scrollTo.jquery.js"></script>
        <script src="<?php echo base_url();?>js/date.js"></script>
        
		<script src="<?php echo base_url();?>jquery/jquery.easing.1.3.js"></script>
        
		<script src="<?php echo base_url();?>js/custom.js"
		<script src="<?php echo base_url();?>jquery/slides.min.jquery.js"></script>></script>
        <script src="<?php echo base_url();?>js/main.js"></script>
        <script src="<?php echo base_url();?>js/jquery-ui-timepicker-addon.js"></script>
        
        <script type="text/javascript" src="<?php echo base_url();?>jquery/jquery.tablesorter.pager.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>jquery/jquery.tablesorter.js"></script>
        <!--
        
		<script src="<?php echo base_url();?>jquery/jquery-1.9.1.js"></script>
		<script src="<?php echo base_url();?>jquery/ui/jquery-ui-1.10.3.custom.js"></script>
        
		<script src="<?php echo base_url();?>js/scrollTo.jquery.js"></script>
        <script src="<?php echo base_url();?>js/date.js"></script>
        
		<script src="<?php echo base_url();?>jquery/jquery.easing.1.3.js"></script>
        
		<script src="<?php echo base_url();?>js/custom.js"></script>
		<script src="<?php echo base_url();?>jquery/slides.min.jquery.js"></script>
        <script src="<?php echo base_url();?>js/main.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>jquery/jquery.tablesorter.pager.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>jquery/jquery.tablesorter.js"></script>
        -->
		      	<style>
			label, input.ui-widget-content { display:block; min-height:3px; }
        	input.text.ui-widget-content { margin-bottom:4px; margin-left:0px; width:90%; padding: .4em;}
			input[type=text].ui-widget-content:focus{
			  @include box-shadow(0 0 5px rgba(81, 203, 238, 1));
			  padding: 3px 0px 3px 3px;
			  margin: 5px 1px 3px 0px;
			  border: 1px solid rgba(81, 203, 238, 1);
			}
			input[type=text]:focus, textarea:focus{
			  @include box-shadow(0 0 5px rgba(81, 203, 238, 1));
			
			  border: 1px solid rgba(81, 203, 238, 1);
			}
        	fieldset { padding:0; border:0; margin-top:15px; }
        	h1 { font-size: 1.2em; margin: .6em 0; }
			div#users-contain { width: 350px; margin: 20px 0; }
			div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
			div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
			.ui-dialog .ui-state-error { padding: .3em; }
			.validateTips { border: 1px solid transparent; padding: 0.3em; }
		
		
		</style>
         <script>
			$(function() {
				var name = $( "#nameMerk" ),
					email = $( "#email" ),
					password = $( "#password" ),
					allFields = $( [] ).add( name ).add( email ).add( password ),
					tips = $( ".validateTips" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Panjang dari " + $('#customer option:selected').text() + " hanya bisa dari" +
							min + " sampai " + max + " (sesuai jumlah hari)." );
						return false;
					} else {
						return true;
					}
				}
				
		 
				$( "#dialog-form-merk" ).dialog({
					autoOpen: false,
					height: 300,
					width: 350,
					modal: true,
					buttons: {
						"Tambah Merk": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid;
							
						   
		 
							if ( bValid ) {
								$( "#users tbody" ).append( "<tr>" +
									"<td>" + name.val() + "</td>" +
									"<td>" + email.val() + "</td>" +
									"<td>" + password.val() + "</td>" +
								"</tr>" );
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
									url: '<?php echo base_url(); ?>driver/addMerk/' + name.val(),
									type: 'POST',
									data:{"bookm": name.val()},
									async: false,
									success: function (result) {
										alert("Penambahan Merk Berhasil");
									}
																			 
								}); 
								$("#merkPlace").load("<?php echo base_url(); ?>driver/ajaxLoadMerk");
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgM" )
					.button()
					.click(function() {
						
						$( "#dialog-form-merk" ).dialog( "open" );
					});
			});
		</script>
        <script>
			$(function() {
				var name = $( "#nameKat" ),
					email = $( "#email" ),
					password = $( "#password" ),
					allFields = $( [] ).add( name ).add( email ).add( password ),
					tips = $( ".validateTips" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Panjang dari " + $('#customer option:selected').text() + " hanya bisa dari" +
							min + " sampai " + max + " (sesuai jumlah hari)." );
						return false;
					} else {
						return true;
					}
				}
				
		 
				$( "#dialog-form-kategori" ).dialog({
					autoOpen: false,
					height: 300,
					width: 350,
					modal: true,
					buttons: {
						"Tambah Kategori": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid;
							
						   
		 
							if ( bValid ) {
								$( "#users tbody" ).append( "<tr>" +
									"<td>" + name.val() + "</td>" +
									"<td>" + email.val() + "</td>" +
									"<td>" + password.val() + "</td>" +
								"</tr>" );
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
									url: '<?php echo base_url(); ?>driver/addCat/' + name.val(),
									type: 'POST',
									data:{"bookn": name.val()},
									async: false,
									success: function (result) {
										alert("Penambahan Kategori Berhasil");
									}
																			 
								}); 
								$("#catPlace").load("<?php echo base_url(); ?>driver/ajaxLoadCat");
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgC" )
					.button()
					.click(function() {
						
						$( "#dialog-form-kategori" ).dialog( "open" );
					});
			});
		</script>
        
       <script>
			$(function() {
				var name = $( "#nameCabang" ),
					email = $( "#email" ),
					password = $( "#password" ),
					allFields = $( [] ).add( name ).add( email ).add( password ),
					tips = $( ".validateTips" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Panjang dari " + $('#customer option:selected').text() + " hanya bisa dari" +
							min + " sampai " + max + " (sesuai jumlah hari)." );
						return false;
					} else {
						return true;
					}
				}
				
		 
				$( "#dialog-form-cabang" ).dialog({
					autoOpen: false,
					height: 300,
					width: 350,
					modal: true,
					buttons: {
						"Tambah Tujuan Barang": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid;
							
						   
		 
							if ( bValid ) {
								$( "#users tbody" ).append( "<tr>" +
									"<td>" + name.val() + "</td>" +
									"<td>" + email.val() + "</td>" +
									"<td>" + password.val() + "</td>" +
								"</tr>" );
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
									url: '<?php echo base_url(); ?>history/addCab/' + name.val(),
									type: 'POST',
									data:{"bookn": name.val()},
									async: false,
									success: function (result) {
										alert("Penambahan Tujuan Barang Berhasil");
									}
																			 
								}); 
								$("#cabPlace").load("<?php echo base_url(); ?>history/ajaxLoadCab");
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 	
				$( "#refreshimgCab" )
					.button()
					.click(function() {
						
						$( "#dialog-form-cabang" ).dialog( "open" );
					});
			});
		</script>
        
        
        
		<!--<script type="text/javascript" src="<?php /*echo base_url();*/?>js/bsn.AutoSuggest_2.1.3_comp.js" charset="utf-8"></script>-->
		
        <!-- 	
        		##############  ##############  ##############  ############## 
         		############## JS FOR CUSTOMER  ##############  ############## 
         		##############  ##############  ##############  ############## 
	       		##############  ##############  ##############  ############## 
        
        
        -->
        	<!-- ## Add  Invoice-->
        
        <script type="text/javascript">
             $(function () {
				var startDateTextBox = $('#inputTglStart');
var endDateTextBox = $('#inputTglEnd');

startDateTextBox.datetimepicker({ 
	onClose: function(dateText, inst) {
		if (endDateTextBox.val() != '') {
			var testStartDate = startDateTextBox.datetimepicker('getDate');
			var testEndDate = endDateTextBox.datetimepicker('getDate');
			if (testStartDate > testEndDate)
				endDateTextBox.datetimepicker('setDate', testStartDate);
		}
		else {
			endDateTextBox.val(dateText);
		}
	},
	onSelect: function (selectedDateTime){
		endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
	}
});
endDateTextBox.datetimepicker({ 
	onClose: function(dateText, inst) {
		if (startDateTextBox.val() != '') {
			var testStartDate = startDateTextBox.datetimepicker('getDate');
			var testEndDate = endDateTextBox.datetimepicker('getDate');
			if (testStartDate > testEndDate)
				startDateTextBox.datetimepicker('setDate', testEndDate);
		}
		else {
			startDateTextBox.val(dateText);
		}
	},
	onSelect: function (selectedDateTime){
		startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
	}
});
				$(document).ready(function(){
					var data = "<?php echo base_url(); ?>history/sug"
					$( "#susgest1" ).autocomplete({
						source: data,
						focus: function( event, ui ) {
							$( "#susgest1" ).val( ui.item.label );
							return false;
				  		},
				  		select: function( event, ui ) {
							$( "#project" ).val( ui.item.value );
							$( "#barcodeHistory" ).val( ui.item.desc );
							$( "#merk" ).val( ui.item.merk );
							$( "#cat" ).val( ui.item.cat );
							$( "#id_item" ).val( ui.item.itemid);
							$( "#stokSkr" ).val( ui.item.itemstok);
							
							return false;
				  		}
					
					});
					
					
					/*.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
      					return $( "<li>" )
						.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
						.appendTo( ul );
					};*/
				})
				$(document).ready(function(){
					var data = "<?php echo base_url(); ?>inItem/sug"
					$( "#susgest1inItem" ).autocomplete({
						source: data,
						focus: function( event, ui ) {
							$( "#susgest1inItem" ).val( ui.item.label );
							return false;
				  		},
				  		select: function( event, ui ) {
							$( "#project" ).val( ui.item.value );
							$( "#barcodeHistory" ).val( ui.item.desc );
							$( "#merk" ).val( ui.item.merk );
							$( "#cat" ).val( ui.item.cat );
							$( "#id_item" ).val( ui.item.itemid);
							$( "#stokSkr" ).val( ui.item.itemstok);
							
							return false;
				  		}
					
					});
				})
 				$("#barcodeHistory").focus();
				$("#barcode").focus();
				$("#barcodeFast").focus();
				$('#barcode').keypress(function(e){
   					if ( e.which == 13 ) // Enter key = keycode 13
    				{
						
						$("#merk").focus();  //Use whatever selector necessary to focus the 'next' input
						return false;
					}
					
				});
				
				$('#barcodeHistory').keypress(function(e){
   					if ( e.which == 13 ) // Enter key = keycode 13
    				{
						
						historyAuto('#barcodeHistory','#autoPlace');
						$("#stok").focus();  //Use whatever selector necessary to focus the 'next' input				
						
						
						return false;
					}
					
				});
				function historyAuto(mydivtext,divname) {
				
					var base_url = "<?php echo base_url(); ?>";
					
					$(divname).load("<?php echo base_url(); ?>history/ajaxGetBarangDet", {nilai : $(mydivtext).val()});
				}
				
				
                 var date = new Date();
                 var currentMonth = date.getMonth();
                 var currentDate = date.getDate();
                 var currentYear = date.getFullYear();
 
                 $(".txtdate2").datepicker({
					 dateFormat: "dd-M-yy" });
             });
   		</script>
        <script>
			 $("#loading").ajaxStart(function () {
				$(this).show();
			 });
			
			 $("#loading").ajaxStop(function () {
			   $(this).hide();
			 });
		</script>
        <script>
		 	function AddDays(days) {
				
				$.get("<?php echo base_url(); ?>invoice/ajaxTanggalAdd/"+$("#datenow").val()+"/"+$("#payterm").val(), function(result){$("#datedue1").val(result)})
				
				
        	}
			
		
			function updateNoInvo(f){
				//$("#noInvoice").text("INV"+$("#noInvoTambah").val()+1);
				var explod = f.noInvoiceR.value.split('INV')
				var invoT = parseInt(explod[1]);
				var invoJum = invoT  +1;
				f.noInvoiceR.value = "INV" + invoJum;
				
				$("#sukses").text("Sukses Menambahkan Data dan Generate PDF")
				
			}
		</script>
        <script>
			function invoViewCustomerPt(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>invoice/ajaxLoadCustList", { perusahaan : $(mydiv).val(),mymode : mode });
			}
			
			
			function viewBillDeliv(mydiv,divname, divnamebill, value,mode){
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>invoice/ajaxLoadCustDeliv", { customer : $(mydiv).val(),mymode : mode });
				$(divnamebill).load("<?php echo base_url(); ?>invoice/ajaxLoadCustBill", { customer : $(mydiv).val(),mymode : mode });
			}
			
			
			function invoJenisBarang1(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>invoice/ajaxLoadBarang", { perusahaan : $(mydiv).val(),mymode : mode });
			}
			
			function reportJenisBarang(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>report/ajaxLoadBarang", { perusahaan : $(mydiv).val(),mymode : mode });
			}
			
			function reportBarangDetail(type, iddriver, mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$('#reportLoad').load("<?php echo base_url(); ?>report/ajaxLoadDetail", {tipe:type, driver: iddriver, perusahaan : mydiv,mymode : mode });
			}
			
		</script>
        
        
        <script>
			function invoDet(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				$(divname).empty();
				$(divname).load("<?php echo base_url(); ?>invoice/ajaxLoadInvoDet", { id : value,mymode : mode });
			}
		</script>
        
        
		<script>
			function viewCarInvo(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				$("#platMobil").empty();
				$(divname).empty();
				$(divname).load("<?php echo base_url(); ?>invoice/ajaxLoadCarList", { car : $(mydiv).val(),mymode : mode });
			}
		</script>
        <script>
			function viewPlat(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				$(divname).empty();
				$(divname).load("<?php echo base_url(); ?>invoice/ajakLoadCarPlat", { plat : $(mydiv).val(),mymode : mode });
			}
		</script>
        
       
		      
        
        
        
        	<!-- ## View Invoice-->
        <script>
			function invoJenisBarang(mydiv,mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>invoice/ajaxSearchInvoice", { pilih : $(mydiv).val(),  nilai : $(mydivtext).val(),mymode : mode, status:$('#paystatus').val(), duestatus:$('#duestatus').val() });
			}
		</script>  
        	<!-- ## View Car-->
        <script>
			function carJenisBarang(mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>car/ajaxSearchCar", {nilai : $(mydivtext).val(),mymode : mode});
			}
		</script>  
        <!-- ## view driver-->
        <script>
			function driverJenisBarang(mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>driver/ajaxSearchDriver", {nilai : $(mydivtext).val(), merk : $('#merk').val(), cat : $('#cat').val(), stok : $('#inputstok').val(),mymode : mode});
			}
		</script>    
           
        <script>
			function historyJenisBarang(mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>history/ajaxSearchHistory", {nilai : $(mydivtext).val(), merk : $('#merk').val(), cat : $('#cat').val(), tanggal : $('#inputTglStart').val(), end : $('#inputTglEnd').val(),mymode : mode});
			}
			function inItemJenisBarang(mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>inItem/ajaxSearchHistory", {nilai : $(mydivtext).val(), merk : $('#merk').val(), cat : $('#cat').val(), tanggal : $('#inputTglStart').val(), end : $('#inputTglEnd').val(),mymode : mode});
			}
		</script>
          
        
         <!-- JS For add bayar-->
        <script>
			/*
		
		
			$(function() {
				var bayar = $( "#bayar" ),
					tanggal = $( "#tanggal" ),
					melalui = $( "#melalui" ),
					allFields = $( [] ).add( bayar ).add( tanggal ).add( melalui ),
					tips = $( ".validateTips" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				
		 
				$( "#dialog-formA" ).dialog({
					autoOpen: false,
					height: 400,
					width: 350,
					modal: true,
					buttons: {
						"Bayar": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							
						   
		 
							if ( bValid ) {
								
								var base_url = "<?php echo base_url(); ?>";
								
    							//var invoId  = invo[1]; 
								var delURL = $(this).data("invoValue").split("div_");
   								var delID  = delURL[1];  
								$.ajax({
									url: '<?php echo base_url(); ?>invoice/ajaxAddBayar/' +delID,
									type: 'POST',
									data:{"bayar": bayar.val(), "tanggal": tanggal.val(), "melalui": melalui.val(), "noInvo": delID, "total":$('#tagihan_'+delID).val(), "duedate":$('#due_'+delID).val()},
									
																			 
								}); 
								
								invoJenisBarang('#selectjenis', '#inputjenis', '#searchPlace', '0');
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( ".ajaxbayar" )
					
					.button()
					.live('click', function(){
						var nomor = $(this).attr("id");
						var spliting = nomor.split("div_");
   						var realVal  = spliting[1]; 
						var tagihan=$('#tagihan_'+realVal).val();
						var bayar=$('#bayar_'+realVal).val();
						var tanggal=$('#tanggal_'+realVal).val();
						var melalui=$('#method_'+realVal).val();
						var pt=$('#perusahaan_'+realVal).val();
						tagihanView = changeFormatRp(tagihan);
						$("#tagihan").val(tagihanView);
						$("#bayar").val(bayar);
						$("#tanggal").val(tanggal);
						$("#melalui").val(melalui);
						$("#headDialog1Bill").text(pt)
						$( "#dialog-formA" ).data("invoValue", $(this).attr("id")).dialog( "open" );
					});
			});*/
		</script>
            
            
            
        <!-- 	
        		##############  ##############  ##############  ############## 
         		############## JS FOR CUSTOMER  ##############  ############## 
         		##############  ##############  ##############  ############## 
	       		##############  ##############  ##############  ############## 
        
        
        -->
        	<!-- ## Add  Customer-->
        <script>
			function copier(f){
				f.nama_ship.value = f.nama.value;
				f.perusahaan_ship.value = f.perusahaan.value
				f.no_telp_ship.value = f.no_telp.value
				f.fax_ship.value = f.fax.value
				
				f.alamat_ship.value = f.alamat.value
				f.alamat_ship_1.value = f.alamat_1.value
				f.alamat_ship_2.value = f.alamat_2.value
				f.rt_ship.value = f.rt.value
				f.rw_ship.value = f.rw.value
				f.kode_ship.value = f.kode_pos.value
				f.kota_ship.value = f.kota.value
				f.provinsi_ship.value = f.provinsi.value
			}
		</script>
        
         <!-- ADD Barang -->
        <script>
			/*$(function() {
				
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Panjang dari " + $('#customer option:selected').text() + " hanya bisa dari" +
							min + " sampai " + max + " (sesuai jumlah hari)." );
						return false;
					} else {
						return true;
					}
				}
				
				$( "#dialog-form-barang" ).dialog({
					autoOpen: false,
					height: 600,
					width: 1000,
					modal: true,
					buttons: {
						"Ok": function() {
							$( this ).dialog( "close" );
							
						  
		 
							
						}
						
					},
					close: function() {
						
					}
				});
		 								

				$('#pilihBarangApa').live('click', function() {
					
			
      
					$( "#dialog-form-barang" ).dialog( "open" );
					
					});
			});
			function invoAjaxLoadBarangSearch(mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>invoice/invoAjaxSearchBarangCar", {nilai : $(mydivtext).val(),mymode : mode});
			}
			function invoAjaxLoadBarangSupirSearch(mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>invoice/invoAjaxSearchBarangDriver", {nilai : $(mydivtext).val(),mymode : mode});
			}*/
		</script>
        
        <!--ADD CUstomer-->
        
         <script>
			$(function() {
				var name = $( "#name-c" ),
					fax = $( "#fax-c" ),
					telp= $( "#telp-c" ),
					alamat = $( "#alamat-c" ),
					rt= $( "#rt-c" ),
					rw = $( "#rw-c" ),
					kode= $( "#kode-c" ),
					kota = $( "#kota-c" ),
					provinsi= $( "#provinsi-c" ),
					allFields = $( [] ).add( name ).add( fax ).add( telp ).add( alamat ).add( rt ).add( rw ).add( kode ).add( kota ).add( provinsi ),
					tips = $( ".validateTips-c" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Field dari " + n + " tidak boleh kosong." );
						return false;
					} else {
						return true;
					}
				}
				
			
		 
				$( "#dialog-form-customer" ).dialog({
					autoOpen: false,
					height: 600,
					width: 550,
					modal: true,
					buttons: {
						"Tambah Data": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid && checkLength( name, "Nama", 1, 255 );
							
						   	bValid = bValid && checkLength( telp, "Telp", 1, 255 );
							/*bValid = bValid && checkLength( fax, "Fax", 1, 255 );
							bValid = bValid && checkLength( alamat, "Nama", 1, 255 );
							
						   //	bValid = bValid && checkLength( rt, "RT", 1, 255 );
							//bValid = bValid && checkLength( rw, "RW", 1, 255 );
							bValid = bValid && checkLength( kode, "Kode", 1, 255 );
							
						   	bValid = bValid && checkLength( kota, "Kota", 1, 255 );
							bValid = bValid && checkLength( provinsi, "Provinsi", 1, 255 );*/
		 
						   /* bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );*/
							// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
							/*bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );*/
							/*bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );*/
		 
							if ( bValid ) {
								
								var base_url = "<?php echo base_url(); ?>";
						
								/*function ajaxWait(){*/
									$.ajax({
										url: '<?php echo base_url(); ?>invoice/addCustTo',
										type: 'POST',
										async: false,
										data:{"name": name.val(), "telp": telp.val(),
												"fax": fax.val(), "alamat": alamat.val(),
												"rt": rt.val(), "rw": rw.val(),
												"kode": kode.val(), "kota": kota.val(), "provinsi": provinsi.val(),
												"custId": $('#pt').val(), "ptId": $('#pt option:selected').text(),
										success: function (result) {
											alert("Penambahan data berhasil");
										}
									},
																		 
									}); 
								/*}*/
								var ptId = $('#pt').val();
								$("#content_datax").load("<?php echo base_url(); ?>invoice/ajaxLoadCustList", {perusahaan : $("#pt").val(),mymode : ""});
								
								/*$("#paytermPlace").load("<?php echo base_url(); ?>invoice/ajaxLoadPayTerm");*/
								
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgC" )
					.button()
					.click(function() {
						if ( $('#pt').val()=="" ) {
						
							alert("Pilih nama perusahaan terlebih dahulu");
						}else{ 
							var namaX=$('#customer option:selected').text();
							var namaP=$('#pt option:selected').text();
							//$("#headDialogBill").text(namaX);
							$("#headDialog1C").text(namaP);
							
							$( "#dialog-form-customer" ).dialog( "open" );
						}
					});
			});
		</script>
        <!-- ADD PAYTERM -->
        <script>
			$(function() {
				var name = $( "#name" ),
					email = $( "#email" ),
					password = $( "#password" ),
					allFields = $( [] ).add( name ).add( email ).add( password ),
					tips = $( ".validateTips" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Panjang dari " + $('#customer option:selected').text() + " hanya bisa dari" +
							min + " sampai " + max + " (sesuai jumlah hari)." );
						return false;
					} else {
						return true;
					}
				}
				
		 
				$( "#dialog-form" ).dialog({
					autoOpen: false,
					height: 300,
					width: 350,
					modal: true,
					buttons: {
						"Tambah Payterm": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid && checkLength( name, "Hari", 1, 3 );
							bValid = bValid && checkLength( email, "Keterangan", 1, 3 );
						   
		 
							if ( bValid ) {
								$( "#users tbody" ).append( "<tr>" +
									"<td>" + name.val() + "</td>" +
									"<td>" + email.val() + "</td>" +
									"<td>" + password.val() + "</td>" +
								"</tr>" );
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
									url: '<?php echo base_url(); ?>invoice/addPayTerm/' + name.val() +'/' +email.val(),
									type: 'POST',
									data:{"bookn": name.val(), "booki": email.val()},
									success: function (result) {
										alert("Penambahan pay term berhasil");
									}
																			 
								}); 
								$("#paytermPlace").load("<?php echo base_url(); ?>invoice/ajaxLoadPayTerm");
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgX" )
					.button()
					.click(function() {
						
						$( "#dialog-form" ).dialog( "open" );
					});
			});
		</script>
        
         <!-- ADD Produsem -->
        <script>
			$(function() {
				var name = $( "#name" ),
					
					allFields = $( [] ).add( name ),
					tips = $( ".validateTips" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		 
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Panjang dari " + $('#customer option:selected').text() + " hanya bisa dari" +
							min + " sampai " + max + " (sesuai jumlah hari)." );
						return false;
					} else {
						return true;
					}
				}
				
		 
				$( "#dialog-formProdusen" ).dialog({
					autoOpen: false,
					height: 300,
					width: 350,
					modal: true,
					buttons: {
						"Tambah Produsen": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							
							
						   
		 
							if ( bValid ) {
								/*$( "#users tbody" ).append( "<tr>" +
									"<td>" + name.val() + "</td>" +
									"<td>" + email.val() + "</td>" +
									"<td>" + password.val() + "</td>" +
								"</tr>" );*/
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
									url: '<?php echo base_url(); ?>car/addProdusen/' + name.val(),
									type: 'POST',
									data:{"bookn": name.val()},
									async: false,
									success: function (result) {
										alert("Penambahan produsen berhasil");
									}
									
																			 
								}); 
								$("#produsenPlace").load("<?php echo base_url(); ?>car/ajaxLoadProdusen");
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgProd" )
					.button()
					.click(function() {
						
						$( "#dialog-formProdusen" ).dialog( "open" );
					});
			});
		</script>
        <!-- ADD DELIVERY -->
        <script>
			$(function() {
				var name = $( "#name-deliv" ),
					fax = $( "#fax-deliv" ),
					telp= $( "#telp-deliv" ),
					alamat = $( "#alamat-deliv" ),
					rt= $( "#rt-deliv" ),
					rw = $( "#rw-deliv" ),
					kode= $( "#kode-deliv" ),
					kota = $( "#kota-deliv" ),
					provinsi= $( "#provinsi-deliv" ),
					allFields = $( [] ).add( name ).add( fax ).add( telp ).add( alamat ).add( rt ).add( rw ).add( kode ).add( kota ).add( provinsi ),
					tips = $( ".validateTips-deliv" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Field dari " + n + " tidak boleh kosong." );
						return false;
					} else {
						return true;
					}
				}
				
				
		 
				$( "#dialog-form-deliv" ).dialog({
					autoOpen: false,
					height: 600,
					width: 550,
					modal: true,
					buttons: {
						"Tambah Payterm": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid && checkLength( name, "Nama", 1, 255 );
							
						   	bValid = bValid && checkLength( telp, "Telp", 1, 255 );
							bValid = bValid && checkLength( fax, "Fax", 1, 255 );
							bValid = bValid && checkLength( alamat, "Nama", 1, 255 );
							
						  // 	bValid = bValid && checkLength( rt, "rt", 1, 255 );
							//bValid = bValid && checkLength( rw, "rw", 1, 255 );
							bValid = bValid && checkLength( kode, "kode", 1, 255 );
							
						   	bValid = bValid && checkLength( kota, "kota", 1, 255 );
							bValid = bValid && checkLength( provinsi, "provinsi", 1, 255 );
		 
		 
							if ( bValid ) {
								
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
										url: '<?php echo base_url(); ?>invoice/addDelivTo',
										type: 'POST',
										async: false,
										data:{"name": name.val(), "telp": telp.val(),
												"fax": fax.val(), "alamat": alamat.val(),
												"rt": rt.val(), "rw": rw.val(),
												"kode": kode.val(), "kota": kota.val(), "provinsi": provinsi.val(),
												"custId": $('#customer').val(), "ptId": $('#pt option:selected').text(),
										success: function (result) {
											alert("Penambahan data berhasil");
										}
									},
																		 
								}); 
								
								//var cuId = $('#customer').val();
								$("#content_deliv").load("<?php echo base_url(); ?>invoice/ajaxLoadCustDeliv", {customer: $('#customer').val()});
								
								
								
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgD" )
					.button()
					.click(function() {
						if ( $('#customer').val()=="" ) {
						
							alert("Pilih nama customer terlebih dahulu");
						}else{ 
							var namaX=$('#customer option:selected').text();
							var namaP=$('#pt option:selected').text();
							$("#headDialog").text(namaX);
							$("#headDialog1").text(namaP);
							
							$( "#dialog-form-deliv" ).dialog( "open" );
						}
					});
			});
		</script>
        <!-- ADD BILL -->
        <script>
			$(function() {
				var name = $( "#name-bill" ),
					fax = $( "#fax-bill" ),
					telp= $( "#telp-bill" ),
					alamat = $( "#alamat-bill" ),
					rt= $( "#rt-bill" ),
					rw = $( "#rw-bill" ),
					kode= $( "#kode-bill" ),
					kota = $( "#kota-bill" ),
					provinsi= $( "#provinsi-bill" ),
					allFields = $( [] ).add( name ).add( fax ).add( telp ).add( alamat ).add( rt ).add( rw ).add( kode ).add( kota ).add( provinsi ),
					tips = $( ".validateTips-bill" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						o.addClass( "ui-state-error" );
						updateTips( "Field dari " + n + " tidak boleh kosong." );
						return false;
					} else {
						return true;
					}
				}
				
			
		 
				$( "#dialog-form-bill" ).dialog({
					autoOpen: false,
					height: 600,
					width: 550,
					modal: true,
					buttons: {
						"Tambah Data": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid && checkLength( name, "Nama", 1, 255 );
							
						   	bValid = bValid && checkLength( telp, "Telp", 1, 255 );
							bValid = bValid && checkLength( fax, "Fax", 1, 255 );
							bValid = bValid && checkLength( alamat, "Nama", 1, 255 );
							
						   	//bValid = bValid && checkLength( rt, "RT", 1, 255 );
							//bValid = bValid && checkLength( rw, "RW", 1, 255 );
							bValid = bValid && checkLength( kode, "Kode", 1, 255 );
							
						   	bValid = bValid && checkLength( kota, "Kota", 1, 255 );
							bValid = bValid && checkLength( provinsi, "Provinsi", 1, 255 );
		 
						   /* bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );*/
							// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
							/*bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );*/
							/*bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );*/
		 
							if ( bValid ) {
								
								var base_url = "<?php echo base_url(); ?>";
						
								
								$.ajax({
										url: '<?php echo base_url(); ?>invoice/addBillTo',
										type: 'POST',
										async: false,
										data:{"name": name.val(), "telp": telp.val(),
												"fax": fax.val(), "alamat": alamat.val(),
												"rt": rt.val(), "rw": rw.val(),
												"kode": kode.val(), "kota": kota.val(), "provinsi": provinsi.val(),
												"custId": $('#customer').val(), "ptId": $('#pt option:selected').text(),
										success: function (result) {
											alert("Penambahan data berhasil");
										}
									},
																		 
								}); 
								
								var cuId = $('#customer').val();
								$("#content_bill").load("<?php echo base_url(); ?>invoice/ajaxLoadCustBill", {customer: cuId});
								
								/*$("#paytermPlace").load("<?php echo base_url(); ?>invoice/ajaxLoadPayTerm");*/
								
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgB" )
					.button()
					.click(function() {
						if ( $('#customer').val()=="" ) {
						
							alert("Pilih nama customer terlebih dahulu");
						}else{ 
							var namaX=$('#customer option:selected').text();
							var namaP=$('#pt option:selected').text();
							$("#headDialogBill").text(namaX);
							$("#headDialog1Bill").text(namaP);
							
							$( "#dialog-form-bill" ).dialog( "open" );
						}
					});
			});
		</script>
        
        
        <!-- ADD SALES PERSON -->
        <script>
			$(function() {
				
				var username = $( "#username" ),
					password = $( "#password" ),
					name= $( "#name" ),
					email = $( "#email" ),
					phone= $( "#phone" ),
					address = $( "#address" ),
					
					allFields = $( [] ).add( username ).add( password ).add( name ).add( email ).add( phone ).add( address ),
					tips = $( ".validateTips-sales" );
		 
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		
				function checkLength( o, n, min, max ) {
					if ( o.val().length > max || o.val().length < min ) {
						//o.addClass( "ui-state-error" );
						updateTips( "Field dari " + n + " tidak boleh kosong." );
						return false;
					} else {
						return true;
					}
				}
				
				function checkava(c, n){
						var base_url = "<?php echo base_url(); ?>";
						var kebenaran = 2;
						$.ajaxSetup({async: false});
						$.post(base_url+"invoice/check_username", { username: c }, 
							function(value){  
							if(value == 1){  
									//show that the username is available 
									 
									kebenaran = 1;
								}else{  
									//show that the username is NOT available  
									 
									
									updateTips( "Username Sudah Digunakan." );
									kebenaran = 0;
								}    
							}
								//if the result is 1  
								
						);
						if(kebenaran ==0){
						return false;}else{
							return true;
						}
						
				}
		 
				$( "#dialog-form-sales" ).dialog({
					autoOpen: false,
					height: 400,
					width: 550,
					modal: true,
					buttons: {
						"Tambah Data": function() {
							
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid && checkava(username.val(), "Username");
							
						   	bValid = bValid && checkLength( password, "Password", 1, 255 );
							bValid = bValid && checkLength( name, "Nama", 1, 255 );
							bValid = bValid && checkLength( email, "Email", 1, 255 );
							
						   	//bValid = bValid && checkLength( rt, "RT", 1, 255 );
							//bValid = bValid && checkLength( rw, "RW", 1, 255 );
							/*bValid = bValid && checkLength( phone, "Telepon", 1, 255 );
							
						   	bValid = bValid && checkLength( address, "Alamat", 1, 255 );*/
							
		 
						   /* bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );*/
							// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
							/*bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );*/
							/*bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );*/
		 
							if (bValid) {
								
								
						
								
								$.ajax({
										url: '<?php echo base_url(); ?>invoice/addSales',
										type: 'POST',
										
										data:{"name": username.val(), "telp": password.val(),
												"fax": name.val(), "alamat": email.val(),
												"rt": phone.val(), "rw": address.val(),
										success: function (result) {
											alert("Penambahan data berhasil");
										}
									},
																		 
								}); 
								
								
								$("#salesPlace").load("<?php echo base_url(); ?>invoice/ajaxLoadSalesPerson");
								
								/*$("#paytermPlace").load("<?php echo base_url(); ?>invoice/ajaxLoadPayTerm");*/
								
								$( this ).dialog( "close" );
								
							}
						},
						Batal: function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
					}
				});
		 
				$( "#refreshimgSales" )
					.button()
					.click(function() {
					
							
							$( "#dialog-form-sales" ).dialog( "open" );
						
					});
			});
		</script>
			<!-- ## View Customer-->
		<script>
			function viewCustomerPt(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				$(divname).empty();
				$(divname).load("<?php echo base_url(); ?>customer/ajaxLoadCustList", { perusahaan : $(mydiv).val(),mymode : mode });
			}
		</script>
        
        
			<!-- ## View Customer-->
		<script>
			function viewCustomerPt(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				$(divname).empty();
				$(divname).load("<?php echo base_url(); ?>customer/ajaxLoadCustList", { perusahaan : $(mydiv).val(),mymode : mode });
			}
		</script>
        <!-- ############## JS FOR CAR ##############-->
        <script>
			function changeFormatRp(num){
				var num
				num = num.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num)) 
					num = "0"; 
				sign = (num == (num = Math.abs(num))); 
				num = Math.floor(num*100+0.50000000001); 
				num = Math.floor(num/100).toString(); 
			
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
				num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3)); 
				var akhirDP = ((sign)?'':'-') + num;
				return akhirDP;
			}
			function viewCar(mydiv,divname,value,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				$(divname).empty();
				$(divname).load("<?php echo base_url(); ?>car/ajaxLoadCarList", { id : $(mydiv).val(),mymode : mode });
			}
		
			function fadeInHitung(divname, mode) {
				$("#hitung:hidden:first").fadeIn('slow')
					
			}
			function enabling(){
				$("#mdfsupir").removeAttr('readonly');
			}
			function enablingfuel(){
				$("#mdffuel").removeAttr('readonly');
				
			}
			
			function hargamdf(){
				
				var mobil = $("#mdfmobil").val();
				var supir = $("#mdfsupir").val();
				supir1 = Number(supir.replace(/[^0-9]+/g,""));
				var fuel = $("#mdffuel").val();
				fuel1 = Number(fuel.replace(/[^0-9]+/g,""));
				var total = parseInt(mobil)+parseInt(supir1)+parseInt(fuel1);
				//var total = mobil+supir1+fuel1;
				
				$("#mdftotal").val(total);
			}
			
			function cicilanHargaFunc(f, num){
				f.harga.value = changeFormatRp(num);
				$("#cicilanHargaJava").text(f.harga.value);
				
				cicilanDpFunc(f);
				cicilanBunga(f);
				cicilanAdm(f);
				diskonFunc(f);
			}
			
			function cicilanDpFunc(f){
				var hargavalue = Number(f.harga.value.replace(/[^0-9]+/g,""));
				if(isNaN(f.depan.value)) 
					f.depan.value = "0"; 
				var dpBay = f.depan.value + "%";
				f.dpBayar1.value = dpBay;
				var dpHitung = parseFloat(f.depan.value);
				var dp= hargavalue * dpHitung /100;
				dp = Math.round(dp);
				var rprice =hargavalue * 3.2 / 100
				rpriceshow = changeFormatRp(rprice)
				$("#rentalPrice").text(rpriceshow);

				var num = dp;
				num = num.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num)) 
					num = "0"; 
				sign = (num == (num = Math.abs(num))); 
				num = Math.floor(num*100+0.50000000001); 
				num = Math.floor(num/100).toString(); 
			
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
				num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3)); 
				var akhirDP = ((sign)?'':'-') + num;
				$("#cicilanHargaDP").text(akhirDP);
				$("#cicilanHargaDPBayar").text(akhirDP);
				var hargamindp = hargavalue-dp;
				var num1 = hargamindp;
				num1 = num1.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num1)) 
					num1 = "0"; 
				sign = (num1 == (num1 = Math.abs(num1))); 
				num1 = Math.floor(num1*100+0.50000000001); 
				
				num1 = Math.floor(num1/100).toString(); 
			
				for (var i = 0; i < Math.floor((num1.length-(1+i))/3); i++) 
				num1 = num1.substring(0,num1.length-(4*i+3))+'.'+ num1.substring(num1.length-(4*i+3)); 
				var akhirDPUI = ((sign)?'':'-') + num1;
				f.bungaHidden.value = hargamindp;
				f.dpHidden.value = dp;
				$("#cicilanHargaDPJava").text(akhirDPUI);
				cicilanBunga(f);
				cicilanAdm(f);
				diskonFunc(f);
			}
			
			function cicilanBunga(f){
				
				if(isNaN(f.bunga.value)) 
				f.bunga.value = "0"; 
				var bungaValue =  parseFloat(f.bunga.value);
				var besarBunga = bungaValue * f.bungaHidden.value / 100 * $('#lamatahun').val();
				besarBunga = Math.round(besarBunga);
				var num = besarBunga;
				num = num.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num)) 
				num = "0";
				sign = (num == (num = Math.abs(num))); 
				num = Math.floor(num*100+0.50000000001); 
				
				num = Math.floor(num/100).toString(); 
			
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
				num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3)); 
				var akhirBunga = ((sign)?'':'-') + num;
				
				$("#cicilanBungaJava").text(akhirBunga);
				var bungaHidden = f.bungaHidden.value;
				var hargaplusbunga = parseInt(bungaHidden)+parseInt(besarBunga);
				var num1 = hargaplusbunga;
				num1 = num1.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num1)) 
				num1 = "0"; 
				sign = (num1 == (num1 = Math.abs(num1))); 
				num1 = Math.floor(num1*100+0.50000000001); 
				
				num1 = Math.floor(num1/100).toString(); 
			
				for (var i = 0; i < Math.floor((num1.length-(1+i))/3); i++) 
				num1 = num1.substring(0,num1.length-(4*i+3))+'.'+ num1.substring(num1.length-(4*i+3)); 
				var akhirDPUI = ((sign)?'':'-') + num1;
				
				$("#cicilanDPBungaJava").text(akhirDPUI);
				
				
				var tahun = $('#lamatahun').val();
				var perBulan;
				var lama;
				switch (tahun)
					{
					  case '1': perBulan = hargaplusbunga/12;
					  			lama = 12;
								break;
					  case '2': perBulan = hargaplusbunga/24;
								lama = 24;
								break;
					  case '3': perBulan = hargaplusbunga/36;
								lama = 36;
								break;
					  case '4': perBulan = hargaplusbunga/48;
								lama = 48;
								break;
					  case '5': perBulan = hargaplusbunga/60;
								lama = 60;
								break;
					  case '6': perBulan = hargaplusbunga/72;
					  			lama = 72;
								break;
					  
					}
				perBulan = Math.round(perBulan);
				var num2 = perBulan;
				num2 = num2.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num2)) 
				num2 = "0"; 
				sign = (num2 == (num2 = Math.abs(num2))); 
				num2 = Math.floor(num2*100+0.50000000001); 
				
				num2 = Math.floor(num2/100).toString(); 
			
				for (var i = 0; i < Math.floor((num2.length-(1+i))/3); i++) 
				num2 = num2.substring(0,num2.length-(4*i+3))+'.'+ num2.substring(num2.length-(4*i+3)); 
				var akhircicilUI = ((sign)?'':'-') + num2;
				f.angsuran.value = "1 | " + lama + " Bulan";
				f.cicilanPerBulanBayar.value = perBulan;
				$("#cicilanPerBulan").text(akhircicilUI);
				$("#angsuran1").text(akhircicilUI);
				
				cicilanAdm(f);
				diskonFunc(f);
				
			}
			
			function cicilanAdm(f){
				var num = f.adm.value;
				num = num.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num)) 
					num = "0"; 
				sign = (num == (num = Math.abs(num))); 
				num = Math.floor(num*100+0.50000000001);
				num = Math.floor(num/100).toString(); 
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
				num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3)); 
				f.adm.value = ((sign)?'':'-') + num;
				
				$("#admUI").text(f.adm.value);
				
				
				
				var adminis= Number(f.adm.value.replace(/[^0-9]+/g,""));
				
				var bayar = parseInt(f.dpHidden.value) + parseInt(f.cicilanPerBulanBayar.value) + parseInt(adminis);
				
				var num1 = bayar;
				num1 = num1.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num1)) 
					num1 = "0"; 
				sign = (num1 == (num1 = Math.abs(num1))); 
				num1 = Math.floor(num1*100+0.50000000001); 
				
				num1 = Math.floor(num1/100).toString(); 
			
				for (var i = 0; i < Math.floor((num1.length-(1+i))/3); i++) 
				num1 = num1.substring(0,num1.length-(4*i+3))+'.'+ num1.substring(num1.length-(4*i+3)); 
				var akhirDPUI = ((sign)?'':'-') + num1;
				f.bayarHid.value = bayar;
				$("#bayar").text(akhirDPUI);
				diskonFunc(f);
			}
			
			function diskonFunc(f){
				
				
				var num = f.diskon.value;
				num = num.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num)) 
					num = "0"; 
				sign = (num == (num = Math.abs(num))); 
				num = Math.floor(num*100+0.50000000001);
				num = Math.floor(num/100).toString(); 
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
				num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3)); 
				f.diskon.value = ((sign)?'':'-') + num;
				
				$("#diskonUI").text(f.diskon.value);
				var diskonHitung= Number(f.diskon.value.replace(/[^0-9]+/g,""));
				var totalBayar = parseInt(f.bayarHid.value) - parseInt(diskonHitung);
				var num1 = totalBayar;
				num1 = num1.toString().replace(/\$|\,|\./g,''); 
				if(isNaN(num1)) 
					num1 = "0"; 
				sign = (num1 == (num1 = Math.abs(num1))); 
				num1 = Math.floor(num1*100+0.50000000001); 
				
				num1 = Math.floor(num1/100).toString(); 
			
				for (var i = 0; i < Math.floor((num1.length-(1+i))/3); i++) 
				num1 = num1.substring(0,num1.length-(4*i+3))+'.'+ num1.substring(num1.length-(4*i+3)); 
				var akhirDPUI = ((sign)?'':'-') + num1;
				akhirDPUI = "Rp " + akhirDPUI;
				$("#bayarAkhir").text(akhirDPUI);
				
			}
		</script>
        <!-- #### JS FOR OWNER ####-->
        <script>
			
		</script>
        
        <!-- #### JS FOR SALES ORDER ####-->
        <script>
			function SOsearch(mydiv,mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>sales/ajaxSearchSO", { pilih : $(mydiv).val(),  nilai : $(mydivtext).val(),mymode : mode});
			}
			
			function SOsearchclear(mydiv,mydivtext,divname,mode) {
				
				var base_url = "<?php echo base_url(); ?>";
				
				$(divname).load("<?php echo base_url(); ?>sales/ajaxSearchSOClear", { pilih : $(mydiv).val(),  nilai : $(mydivtext).val(),mymode : mode});
			}
			
			$(function() {
				$('#baseUrl').click(function() {
					window.location = $(this).attr('href') + '/' + $('#dariSO').val();
					return false;
				});
			});
		</script>    
        
        
        
        <!-- #### JS FOR GENERAL USES ####-->
        <script type="text/javascript">
             $(function () {
 
                 var date = new Date();
                 var currentMonth = date.getMonth();
                 var currentDate = date.getDate();
                 var currentYear = date.getFullYear();
 
                 $(".txtdate").datepicker({
                     minDate: new Date(currentYear, currentMonth, currentDate),
					 dateFormat: "yy-mm-dd" });
             });
   		 </script>
         <script type="text/javascript">
             $(function () {
 
                 var date = new Date();
                 var currentMonth = date.getMonth();
                 var currentDate = date.getDate();
                 var currentYear = date.getFullYear();
 
                 $(".txtdate1").datepicker({
					 dateFormat: "yy-mm-dd" });
             });
   		 </script>
         
         <script type="text/javascript">
			$(function() {
				$("table")
					.tablesorter({widthFixed: true}) 
					<!--.tablesorter({debug: true})-->
					.tablesorterPager({container: $("#pager1")});
			});
			
         </script>
       
       
       
        <?php
		if(isset($javascript) ){
			foreach($javascript as $script){ ?>
				<script src="<?php echo base_url();?>js/<?php echo $script; ?>" type="text/javascript"></script>
			<?php }
		}
		?>
        <?php if(isset($tinymce) ) include "tinymce.php"; ?>
	</head>
	<body>
    	<div class="background_" id="background_data"></div>
    	<div class="container_">
            <div class="banner">
            	<div class="banner_content">
                	<a href="<?php echo base_url();?>" class="menu" title="home">
                        <div class="banner_logo">
                            <img src="<?php echo base_url();?>img/logo1.png" />
                        </div>                
                        
                       	
                        
                    </a>
                    <div id="login">
                    	<?php if(Auth::isLoggedIn()){ ?>
                        	<div class="welcome_user">Selamat Bekerja, <a id="user_menu_close" class="usermenu button_red" alt="hide"> <img src="<?php echo base_url();?>img/arrow_right.png" /> <?php echo get_username($this->session->userdata("user_id"));?> </a></div>
                            <div id="user_menu">
                                <?php $this->load->view("general/user_menu"); ?>
                                	
                            </div>
                     	<?php } else{
							
                       }?>
					
                       </div>  
                    
                   	<div class="clear"></div>
                    <?php if(Auth::isLoggedIn()){?>
                    <div class="menu_list">
                    	
                        	<?php $this->load->view("general/menu_list"); ?>
                        
                        <?php }
						 ?>
                    </div>
                    
                    
                    
            	</div>
            </div>
			<?php date_default_timezone_set('Asia/Bangkok');?>
        	<div class="container">
            	 
               	<div class="message"><br /></div>
                <div class="content">
                	
                	                   
                        <div class="clear"></div>
                        <!--commented from here
	                    <!--<div id="social_media">
                       
                        	<?php /* if( Auth::isLoggedIn() && $this->session->userdata("have_cart") != ""){ ?>
                            <a href="<?php echo base_url();?>product/viewcart" title="You have cart"><span id="you_have_cart">You have</span> <img src="<?php echo base_url();?>img/cart.png" /></a>
                            <?php } ?>
                            <?php $this->load->view("general/social_media"); */?>
                        </div>-->
					
					